#!/bin/bash

echo "执行打包脚本====================="

echo "请选择打包的平台"
echo ""
echo "1、构建IOS的Ipa包"
echo "2、构建安卓的Apk包"
echo "3、不传默认是构建全平台"
echo "4、退出"

# 脚本执行过程中，等待用户输入
read -p "请输入选择类型: " input
echo "****************"
echo "您选择了:[${input}]"

echo "请选择构建分析包还是正常包"
echo ""
echo "1、构建分析包"
echo "其他或者不填则为正常包"

# 脚本执行过程中，等待用户输入
read -p "请输入选择类型: " input1
echo "****************"
echo "您选择了:[${input1}]"

path=$(pwd);
dbug_buildPath=${path}/build/dbug_build

number=${1};
name=${2};
if [[ "${number}" == "" || "${name}" == "" ]]; then
     
    read -p "您没有输入打包的number和build version号，是否用默认(y/n),为y则默认numbe：1,version code为：1.0.0,为n就立马退出: " input2
    if [[ "${input2}" == "y" || "${input2}" == "Y" ]]; then
        name="1.0.0";
        number="1"
    else
        echo "你选择了N或者n，程序退出！！！"
        exit;
    fi
fi

type="0";
if [[ "${input}" == "1" || "${input}" == "2" || "${input}" == "3" ]]; then
	if [[ -d $build/dbug_build ]]; then
		echo "删除文件:${dbug_buildPath}"
		rm -rf $dbug_buildPath
	fi
fi
if [[ "${input1}" == "1" ]]; then
	type="1";
	echo "打分析大小包。。。。"
else
	echo "打正常包。。。。"
fi

echo "打包类型type=${type},number=${number} name=${name}"
if [[ "${input}" == "1" ]]; then
	echo "======构建ios开始======"
	sh ./androidIpa.sh $type "${number}" "${name}"
	echo "======构建ios结束======"
elif [[ "${input}" == "2" ]]; then
	echo "======构建安卓开始======"
	sh ./androidApk.sh $type "${number}" "${name}"
	echo "======构建安卓结束======"
elif [[ "${input}" == "3" ]]; then
	echo "======构建安卓开始======"
	sh ./androidApk.sh $type "${number}" "${name}"
	echo "======构建安卓结束======"

	echo "======构建ios开始======"
	sh ./androidIpa.sh $type "${number}" "${name}"
	echo "======构建ios结束======"
else
	echo "你选择有误，已经退出==="
	exit;
fi

echo "执行打包脚本结束================="
